<template>
  <div>
    <span v-for="item in buttonTop" :key="item.id">
      <Button type="primary" class="mr20"
              v-if="item.name.indexOf('xinzeng')!=-1 || item.name.indexOf('xinjian')!=-1 || item.name.indexOf('tianjia')!=-1 || item.name.indexOf('zengyuan')!=-1"
              @click="handleAdd">{{
          item.meta.title
        }}</Button>
      <Button class="mr20" v-if="item.name.indexOf('shanchu')!=-1" @click="batchDelete">{{ item.meta.title }}</Button>
<!--      <Button class="mr20" v-if="item.name.indexOf('daoru')!=-1" @click="handleImport">{{ item.meta.title }}</Button>-->
      <Button class="mr20" v-if="item.name.indexOf('daochu')!=-1" @click="handleExport">{{ item.meta.title }}</Button>
      <!--  企业同步通讯录    -->
      <Button type="primary" class="mr20" v-if="item.name.indexOf('zuzhijiegou')!=-1" @click="handleTongbu">{{
          item.meta.title
        }}</Button>
    </span>
  </div>
</template>

<script>
export default {
  name: "buttonMenu",
  data() {
    return {
      buttonTop: [],
    }
  },
  watch: {
    $route(val) {
      let buttonMenu = this.buttonMenu(this.$route.name);
      this.buttonTop = buttonMenu.buttonTop;
      if (this.buttonTop.find(item => item.name.indexOf("daoru") != -1)) {
        localStorage.setItem('import', true);
      } else {
        localStorage.setItem('import', false);
      }
    }
  },
  created() {
    let buttonMenu = this.buttonMenu(this.$route.name);
    this.buttonTop = buttonMenu.buttonTop;
    if (this.buttonTop.find(item => item.name.indexOf("daoru") != -1)) {
      localStorage.setItem('import', true);
    } else {
      localStorage.setItem('import', false);
    }
  },
  methods: {
    handleAdd() {
      this.$emit("handleAdd", true);
    },
    batchDelete() {
      this.$emit("batchDelete", true);
    },
    handleImport() {
      this.$emit("handleImport", true);
    },
    handleExport() {
      this.$emit("handleExport", true);
    },
    handleTongbu() {
      this.$emit("handleTongbu", true);
    },
  }
}
</script>

<style scoped lang="less">

</style>
